<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">添加区域</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-2 am-form-label form-require"> 区域类型 </label>
                                <div class="am-u-sm-10 ">
                                    <label class="am-radio-inline ch">
                                        <input type="radio" name="user[type]"
                                               value="1" >
                                        城市
                                    </label>
                                    <label class="am-radio-inline ch">
                                        <input type="radio" name="user[type]"
                                               value="2">
                                        区域
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group isshow" style='display:none'>
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">上级名称 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="user[pid]" data-am-selected="{btnSize: 'sm'}">
                                        <?php if (isset($roleList)): foreach ($roleList as $role): ?>
                                            <option value="<?= $role['id'] ?>"> <?= $role['name'] ?></option>
                                        <?php endforeach; endif; ?>
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">区域名称 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="user[name]"
                                           value="" placeholder="请输入区域名称" required>
                                </div>
                            </div>
                            <div class="am-form-group isshow" style='display:none'>
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">区域属性 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="user[datatype]" data-am-selected="{btnSize: 'sm'}" required>
                                            <option value="1"> 新房</option>
                                            <option value="2"> 二手房</option>
                                            <option value="3"> 文旅</option>
                                            <option value="4"> 其他</option>
                                    </select>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交
                                    </button>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        //获取单选框选中的值
        $('.ch').click(function(){
            var cs=$('input[name="user[type]"]:checked').val();
            if(cs==1){
                $('.isshow').hide();
            }
            if(cs==2){
                $('.isshow').show();
            }
        })

        /**
         * 表单验证提交
         * @type {*}
         */
        $('#my-form').superForm();

    });
</script>
